"""
以下是几个参考:
  nnUNet/nnunetv2/dataset_conversion/Dataset223_AMOS2022postChallenge.py | Dataset137_BraTS21.py
  nnUNet/nnunetv2/experiment_planning/plan_and_preprocess_entrypoints.py
"""

import os
from nnunetv2.dataset_conversion.generate_dataset_json import generate_dataset_json

import shutil

dataset_path = "nnUNetFrame/DATASET/nnUNet_raw/Dataset004_Hippocampus"
imagesTr = os.path.join(dataset_path, 'imagesTr')
# imagesTs = os.path.join(dataset_path, 'imagesTs')
# labelsTr = os.path.join(dataset_path, 'labelsTr')

# 'output_folder', 'channel_names', 'labels', 'num_training_cases', and 'file_ending'
generate_dataset_json(
    ".",
    {0: 'nonCT'},
    {"background": 0, "Anterior": 1, "Posterior": 2},
    len(os.listdir(imagesTr)),
    '.nii.gz',
    dataset_name="Dataset004_Hippocampus"
)
os.remove(os.path.join(dataset_path, "dataset.json"))
shutil.move("dataset.json", dataset_path)


